
#local variables 
TOLERANCE=10
iface_name=`cat config/lan_setup.conf | awk '{ print $2 }'`
ip_address=`cat config/lan_setup.conf | awk '{ print $3 }'`
node_name=`cat config/node_name_setup.conf | awk '{ print $2 }'`
IS_GW=`cat config/gw_setup.conf | awk ' { print $2 } ' `
NUM_OF_DNS=`cat /etc/resolv.conf | grep nameserver | wc -l`
cat /etc/resolv.conf | grep nameserver > config/resolv.conf

echo $iface_name
echo $ip_address
NODE_NAME=`expr substr "$node_name" 1 9`
echo $NODE_NAME

echo "Now starting the Heart-Beat exchange...."
sleep 2

cd tools/raw/


gcc -o inject inject_hb.c

if [ "$IS_GW" = "yes" ]; then
	./inject $iface_name $ip_address $NODE_NAME 1 $NUM_OF_DNS &
else
	./inject $iface_name $ip_address $NODE_NAME 0 $NUM_OF_DNS &
fi

echo "Heart-Beats are being sent. Now starting sniffing...."
sleep 2


gcc -o sniff sniff_hb.c manifold_routing.c

if [ "$IS_GW" = "yes" ]; then
	./sniff $iface_name $MYMANET_TOLERANCE 1 $MYMANET_IS_EMB_DEV
else
	./sniff $iface_name $MYMANET_TOLERANCE 0 $MYMANET_IS_EMB_DEV
fi
	

rmmod manifold
echo "Done. Module has been removed forcibly."
